package o;

import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.Key;
import java.util.Arrays;
import java.util.Map;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public final class deo {
    public static String ॱ(Map<String, String> map, String str) {
        String str2;
        String[] strArr = new String[map.size()];
        map.keySet().toArray(strArr);
        Arrays.sort(strArr);
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < map.size(); i++) {
            str2 = (String) map.get(strArr[i]);
            if (str2 != null) {
                stringBuilder.append(strArr[i]).append('=').append(str2).append('&');
            }
        }
        str2 = stringBuilder.toString();
        if (str2.length() > 0) {
            str2 = str2.substring(0, str2.length() - 1);
        }
        return ˋ(str2, str);
    }

    private static String ˋ(String str, String str2) {
        try {
            byte[] bytes = URLEncoder.encode(str, "UTF-8").getBytes("UTF-8");
            Key secretKeySpec = new SecretKeySpec(str2.getBytes("UTF-8"), "HmacSHA256");
            Mac instance = Mac.getInstance("HmacSHA256");
            instance.init(secretKeySpec);
            return new String(ˎ(instance.doFinal(bytes)), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            deg.ˏ.ˏ("WlanZoneUtils", "UnsupportedEncodingException error");
        } catch (Exception e2) {
            deg.ˏ.ˏ("WlanZoneUtils", "Exception erro");
        }
        return null;
    }

    private static byte[] ˎ(byte[] bArr) {
        return Base64.encode(bArr, 0);
    }
}
